from neo4j import GraphDatabase

from group_profile.config_util import ConfigUtil


class Neo4jDriver:

    def __init__(self):
        url, user, password = ConfigUtil.get_neo4j()

        with GraphDatabase.driver(url, auth=(user, password)) as driver:
            driver.verify_connectivity()
        self.driver = driver

    def execute(self, query):
        records, summary, keys = self.driver.execute_query(query)
        return records, summary, keys


if __name__ == '__main__':

    neo4j_driver = Neo4jDriver()
    records, summary, keys = neo4j_driver.execute('match (e:User)-[r]->(lac:Lac) set e.community_id = 1')

    for record in records:
        print(record.data())
